package controller;

import dto.QueryParserDTO;
import dto.QueryResultDTO;

public class ControllerTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		String createdb = "create    DATABASE   a";
		String createTbl = "create table a (col1 string)";

		String insert = "  insert into a (a, b, c) values ('val1', 'val2', 'val3')";
		String select = "select * from tbl1";
		String select1 = "select a from tbl1";
		String select2 = "select a from tbl1 where a='a'";		
		String join = "select * from tbl1 join tbl3 on tbl1.a = tbl3.col2";
		String use = "use 'b'";
		
		QueryController ctrl = new QueryController(use);
		ControllerConfiguration.DEFAULT_DATABASE = "b";
		QueryResultDTO info = null;
		try {
			info = ctrl.executeQuery();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println(info);

		// ArrayList<String> queries = new ArrayList<String>();
		//
		// // SELECT column_list FROM table-name
		// // [WHERE Clause]
		// // [GROUP BY clause]
		// // [HAVING clause]
		// // [ORDER BY clause];
		// String selectCols = "(?i)(\\*|(\\w+)(\\s*,\\s*(\\w+))*)";
		//
		// String and =
		// "(\\s+(?i)and\\s+((\\w+|\\d+)\\s*=\\s*(\\'\\w+\\'|\\d+)))*";
		// String or =
		// "(\\s+(?i)or\\s+((\\w+|\\d+)\\s*=\\s*(\\'\\w+\\'|\\d+)))*";
		// String where =
		// "(\\s+(?i)where\\s+((\\w+|\\d+)\\s*=\\s*(\\'\\w+\\'|\\d+)))*"
		// + and + or;
		//
		// String groupby =
		// "(\\s+(?i)(group\\s+by\\s+)(\\w+)(\\s*,\\s*\\w+)*)*";
		//
		// String having = "(\\s+(?i)having)*";
		//
		// String orderby =
		// "(\\s+(?)order\\s+(?i)by\\s+(\\w+)(\\s*,\\s*\\w+)*)*";
		// String select = "\\s*(?i)select\\s+" + selectCols
		// + "\\s+(?i)from\\s+\\w+" + where + groupby + orderby + "\\s*";
		//
		// queries.add("select * from a");
		// queries.add("select aAAa , b FROM a");
		// queries.add("select aAAa , b FROM a where a =3");
		// queries.add("select aAAa , b FROM a where a =3 or d=2");
		// queries.add("select aAAa , b FROM a where a =3 and d=2");
		// queries.add("select aAAa , b FROM a GROUP BY e");
		// queries.add("select aAAa , b FROM a where a =3 and d=2 group by e,f, g");
		// queries.add("select aAAa , b FROM a where a =3 order by col");
		//
		// // INSERT INTO TABLE_NAME
		// // [ (col1, col2, col3,...colN)]
		// // VALUES (value1, value2, value3,...valueN);
		// String insertCols =
		// "\\[\\s*\\(\\s*(\\w+)(\\s*,\\s*\\w+)*\\s*\\)\\]\\s*";
		// String insertValues =
		// "\\(\\s*((\\'\\w+\\')|\\d+)(\\s*,\\s*((\\'\\w+\\')|\\d+))*\\s*\\)\\s*";
		// String insert = "\\s*(?i)insert\\s+(?i)into\\s+(\\w+)\\s+" +
		// insertCols
		// + "\\s+(?i)values\\s+" + insertValues + "\\s*";
		//
		// queries.add("insert into tbl [(a,b,c)]");
		// queries.add("insert into tbl [(a,b,c)] values");
		// queries.add("insert into tbl [(a,b,c)] values (a, b, c)");
		// queries.add("INSERT  INTO  tbl [ (a ,b ,c)] VALUES ('a' , 15, 'c')  ");
		//
		// // CREATE TABLE table_name
		// // (column_name1 datatype,
		// // column_name2 datatype,
		// // ... column_nameN datatype
		// // );
		// String createTableCols =
		// "\\(\\s*(\\w+\\s+\\w+)(\\s*,\\s*(\\w+\\s+\\w+))*\\s*\\)";
		// String createTable = "\\s*(?i)create\\s+(?i)table\\s+\\w+\\s+"
		// + createTableCols;
		//
		// queries.add("create table a (col1 string)");
		// queries.add("create table a (col1 string, col2 int, col3 int)");
		//
		// // CREATE TABLE table_name
		// // (column_name1 datatype,
		// // column_name2 datatype,
		// // ... column_nameN datatype
		// // );
		// // String createTableCols =
		// // "\\(\\s*(\\w+\\s+\\w+)(\\s*,\\s*(\\w+\\s+\\w+))*\\s*\\)";
		// String createDatabase = "\\s*(?i)create\\s+(?i)database\\s+\\w+\\s+";
		//
		// queries.add("create database a ");
		// queries.add("create DATABASE a ");
		//
		// // UPDATE table_name
		// // SET column_name1 = value1,
		// // column_name2 = value2, ...
		// // [WHERE condition]
		// String updateData =
		// "\\w+\\s*=\\s*(\\'\\w+\\'|\\d+)(\\s*,\\s*(\\w+\\s*=\\s*(\\'\\w+\\'|\\d+)))*\\s*";
		// String update = "\\s*(?i)update\\s+\\w+\\s+(?i)set\\s+" + updateData;
		//
		// queries.add("update tbl set a = 1, b = v");
		// queries.add("update tbl set a = 1, b = 'v'");
		//
		// // DELETE FROM table_name [WHERE condition];
		// String delete = "\\s*(?i)delete\\s+(?i)from\\s+\\w+\\s*" + where;
		//
		// queries.add("delete from tbl where a = 1");
		// queries.add("delete from tbl ");
		// queries.add("delete from tbl where a = 1 or c = a");
		//
		// // Drop table table_name;
		// String dropTable = "\\s*(?i)drop\\s+(?i)table\\s+\\w+\\s*";
		//
		// queries.add("drop table a  ");
		// queries.add("DROP TABLE a  ");
		//
		// // Drop table table_name;
		// String dropDatabase = "\\s*(?i)drop\\s+(?i)database\\s+\\w+\\s*";
		//
		// queries.add("drop database a  ");
		// queries.add("DROP database a  ");
		//
		// for (String string : queries) {
		// if (string.matches(createDatabase)) {
		// System.out.println("\"" + string + "\"");
		// }
		// }

		// Pattern p = Pattern.compile("(love|,)");
		// String[] result = p.split("a  b");
		// System.out.println(result[0]);
	}
}

